#include "StdAfx.h"
#include "TexOrder.h"


TexOrder::TexOrder(void)
{
}


TexOrder::~TexOrder(void)
{
}

void TexOrder::init()
{
    m_uiOrderId     = 0;
    m_strCustomer   = "";
    m_strDate       = "";
    m_vecOrderItem.clear();
    m_uiAllItemsPcsCount = 0;
    m_fAllItemsNumSum    = 0;
    m_fAllItemsMoneySum  = 0;
}

unsigned int TexOrder::getOrderId() const
{ 
    return m_uiOrderId; 
}

void TexOrder::setOrderId(unsigned int uiOrderId)
{ 
    m_uiOrderId = uiOrderId; 
}

string TexOrder::getCustomer() const
{ 
    return m_strCustomer; 
}

void TexOrder::setCustomer(string strCustomer)
{ 
    m_strCustomer = strCustomer; 
}

string TexOrder::getDate() const
{ 
    return m_strDate; 
}

void TexOrder::setDate(string strDate)
{ 
    m_strDate = strDate; 
}

void TexOrder::addOrderItem(TexOrderItem item)
{
    m_vecOrderItem.push_back(item);
}

void TexOrder::calcData()
{
    unsigned int   uiAllItemsPcsCountTmp = 0;
    float          fAllItemsNumSumTmp    = 0;
    float          fAllItemsMoneySumTmp  = 0;

    vector<TexOrderItem>::const_iterator iter = m_vecOrderItem.begin();
    for (; iter != m_vecOrderItem.end(); ++iter)
    {
        uiAllItemsPcsCountTmp += iter->getPcsCount();
        fAllItemsNumSumTmp    += iter->getNumSum();
        fAllItemsMoneySumTmp  += iter->getMoneySum();
    }

    this->m_uiAllItemsPcsCount  = uiAllItemsPcsCountTmp;
    this->m_fAllItemsNumSum     = fAllItemsNumSumTmp;
    this->m_fAllItemsMoneySum   = fAllItemsMoneySumTmp;
}


unsigned int TexOrder::getAllItemsPcsCount() const
{
    return m_uiAllItemsPcsCount;
}

float TexOrder::getAllItemsNumSum() const
{
    return m_fAllItemsNumSum;
}

float TexOrder::getAllItemsMoneySum() const
{
    return m_fAllItemsMoneySum;
}

void TexOrder::getStatInfo(vector<ItemStatInfo>& vecPair)
{
    ItemStatInfo itemStat;
    vector<TexOrderItem>::const_iterator iter = m_vecOrderItem.begin();
    for (; iter != m_vecOrderItem.end(); ++iter)
    {
        itemStat.iPcsCnt = iter->getPcsCount();
        itemStat.fNumSum = iter->getNumSum();
        itemStat.fMoney  = iter->getMoneySum();
        vecPair.push_back(itemStat);
    }
}